#pragma once
#include "MyRuleStruct.h"
#include <WinIoCtl.h>
#include "Process.h"
#include "DriverLoad.h"
#include "File.h"
#include "reg.h"
#include "DriverMon.h"
#include "NetMon.h"


#define INFNAME _T("FirstDriver.inf")
#define LINKNAME _T("\\\\.\\MyProtect")
#define SERVICENAME		_T("FirstDriver")
#define HIPSPORTNAME _T("\\FirstDriverPort")


class CDriverLoad;
class BaseDialog;



typedef WhatTodo(*NotifyProc)(Param& opdata);

#define  MAXPATHLEN 270 
#define THREAD_COUNT 5
#define requestCount 5

class CMyComunicate
{
public:
	CMyComunicate();
	~CMyComunicate();
public:
	BOOL	InitDriver();
	BOOL	OnExitProcess();
	BOOL	UninsDriver();
	BOOL	StartProcMon(BOOL Start, BaseDialog *pDlg);
	BOOL	StartSelfProtect(BOOL Start, BaseDialog *pDlg);
	BOOL	StartRegMon(BOOL Start, BaseDialog *pDlg);
	BOOL	StartDrvMon(BOOL Start, BaseDialog *pDlg);
	BOOL	StartToWork();
	BOOL StartProtect(BOOL Start, BaseDialog *pDlg);
	BOOL StartFileMon(BOOL Start, BaseDialog *pDlg);
	VOID	CloseComplete();
	BOOL StartSendPermitOrStopAll(BOOL bPermit, BaseDialog *pDlg);

	BOOL StartAddBlackList(BOOL bStart, BaseDialog *pDlg);
	BOOL StartAddWhiteList(BOOL bStart, BaseDialog *pDlg);
	BOOL StartHide(BOOL Start, BaseDialog *pDlg);

	BOOL StartAddMonitorFile(BOOL bStart, BaseDialog *pDlg);
	BOOL StartAddMonitorNet(BOOL bStart, BaseDialog *pDlg);
	BOOL StartNetMonitor(BOOL bStart, BaseDialog *pDlg);

	static unsigned int __stdcall MonitorProc(LPVOID param);
	VOID		SetNotify(NotifyProc notify, PVOID pClass);
public:
	TCHAR		m_errStr[100];
	CDriverLoad* m_pScmDrvCtrl;
	PVOID		m_pClass;
	CProcess m_cProcess;
	File m_cFile;
	reg m_cReg;
	CDriverMon m_cDriverMon;
	CNetMon m_cNetMon;

private:
	HANDLE		m_port;
	HANDLE		m_completion;
	NotifyProc  m_funcNotify;
	HANDLE		m_threads[THREAD_COUNT];
	PSCANNER_MESSAGE m_msg[THREAD_COUNT];
	void*		m_pMagPoint[requestCount*THREAD_COUNT];
	int			m_iMsgCount;

};

